package com.opmsys.mapper;


import com.github.pagehelper.Page;
import com.opmsys.pojo.dto.AccidentPageDTO;
import com.opmsys.pojo.entity.Accident;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface AccidentMapper {


    /**
     * 新增一条事故记录
     * @param accident
     */
    @Insert("insert into t_accident" +
            "(accident_date, accident_type, accident_details, accident_cause, accident_status, `person_number`, pump_id) " +
            "VALUES (#{accidentDate}, #{accidentType}, #{accidentDetails}, #{accidentCause}, #{accidentStatus}, #{personNumber}, #{pumpId})")
    void insert(Accident accident);

    /**
     * 动态sql按id更新非空信息列
     * @param accident
     */
    void update(Accident accident);

    /**
     * 按id删除
     * @param id
     */
    @Delete("delete from t_accident where id = #{id}")
    void deleteById(Integer id);

    /**
     * 分页查询事故记录
     * @param accidentPageDTO
     * @return
     */
    Page<Accident> pageQuery(AccidentPageDTO accidentPageDTO);
}
